Skip to content

Fix database upgrade when the debug column is missing - #356

Merged
TheWitness merged 2 commits into
Cacti:developfrom
alcatron:fix/debug-column-upgrade
Nov 16, 2026
Merged

TheWitness merged 2 commits into
Cacti:developfrom
alcatron:fix/debug-column-upgrade

Conversation

@alcatron

@alcatron alcatron commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Upgrading an installation without weathermap_maps.debug currently runs ADD COLUMN debug debug set(...). The duplicated name is interpreted as a data type, so the column is not added. I hit this during a live upgrade to develop; applying the corrected ALTER statement added the column successfully.

Remove the duplicated name, keeping the existing values and default. Also repairs installations already stamped as 2.1 by the failed upgrade. That recovery checks only the missing debug column, without rerunning unrelated migrations, and retries on a later call if the column is still absent. Includes regression coverage and a 2.1 changelog entry.

Validation:

  • Both the original SQL regression and the same-version recovery regression fail before their respective fixes and pass afterwards.
  • All five upgrade tests pass (8 assertions) on PHP 8.3 / PHPUnit 11.5.
  • PHP syntax and diff whitespace checks pass.

The test checks the SQL emitted by the upgrade using the existing database stubs; the corrected statement was also applied successfully on the live MariaDB installation. The full Pest suite is left to CI.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the database upgrade fix.

No open issues 🎉

What changed in this PR

Fixes Weathermap’s database upgrade when weathermap_maps.debug is missing, preserving the column’s existing values and default.

Changes:

  • Removes the duplicated column name from the upgrade SQL.
  • Adds a regression test for the missing-column statement.
  • Records the fix in the 2.1 changelog.
File Description
tests/​Unit/​WeathermapUpgradeTest.php Verifies the upgrade emits the corrected SQL statement.
includes/​database.php Corrects the ALTER TABLE statement for the missing debug column.
CHANGELOG.md Documents the database upgrade fix.

Review effort: Balanced

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The corrected ALTER statement is valid, and all three upgrade tests pass locally. I also verified the SQL against MariaDB 11.8, including preservation of existing map rows. However, the complete upgrade path does not repair an installation that has already encountered the malformed statement: the earlier run stamps version 2.1 despite the failure, so applying this PR skips the corrected migration. Please cover that recovery state before merging.

Comment thread includes/database.php Resolved
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 03ff01f into Cacti:develop Nov 16, 2026
3 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants